<template>
	<view>
		<view class="details">
			<text class="title">惩罚名称: {{ cfName }}</text>
			<text>时间: {{ cfDate }}</text>
			<text>事由: {{ reason }}</text>
			<text v-if="cfLevel">等级: {{ cfLevel }}</text>
			<text>描述: {{ describe || "无" }}</text>
		</view>
	</view>
</template>

<script>
	import isHaveBug from "../../../utils/bug";
	import {
		getPunish
	} from "@/api/work/punish";

	export default {
		data() {
			return {
				cfName: "",
				cfDate: "",
				reason: "",
				cfLevel: "",
				describe: "",
			};
		},
		onLoad(options) {
			const id = options.id;
			this.fetchDetails(id);
		},
		onBackPress() {
			// uni.redirectTo({url: ''})
			if (isHaveBug("HR-APP-028")){
				this.$tab.reLaunch("/pages/index");
				return true
			}else{
				return false
			}
		},
		methods: {
			fetchDetails(id) {
				getPunish(id).then((response) => {
					const data = response.data;
					this.cfName = data.cfName;
					this.cfDate = data.cfDate;
					this.reason = data.cfReason;
					if (!isHaveBug("HR-APP-027")) {
						this.cfLevel = data.cfLevel;
					}
					this.describe = data.describe || "无";
				});
			},
		},
	};
</script>

<style scoped>
	/* 页面整体样式 */
	view {
		padding: 20px;
		background-color: #f5f5f5;
	}

	/* 返回按钮样式 */
	.back-button {
		font-size: 16px;
		color: #007aff;
		margin-bottom: 20px;
		display: flex;
		align-items: center;
	}

	/* 详情内容样式 */
	.details {
		background-color: #ffffff;
		padding: 15px;
		border-radius: 8px;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	}

	/* 文字样式 */
	text {
		display: block;
		font-size: 16px;
		color: #333;
		margin-bottom: 10px;
	}

	/* 加粗的标题 */
	.title {
		font-weight: bold;
		font-size: 18px;
		margin-bottom: 15px;
	}
</style>